package com.mano.mall.gateway.handler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mano.mall.gateway.handler.factory.FactoryHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.netflix.zuul.context.RequestContext;

/**
 * 责任链调用方
 */
@Component
public class ResponsibilityClient {

	@Autowired
	private FactoryHandler factoryHandler;
	/**
	 * 责任链调用
	 */
	public void responsibility(RequestContext ctx, String ipAddres, HttpServletRequest request,
			HttpServletResponse response) {
		GatewayHandler handler = factoryHandler.getHandler();
		if(null != handler){
			handler.service(ctx, request, response);
		}

	}
}
